﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NumericalCalculationsTest
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class NumericalUnitTest
    {
        public NumericalUnitTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestMethodTest()
        {
            NumericalCalculations.Functions f = new NumericalCalculations.Functions();
            int[] niz = new int[3];
            niz[0] = 2;
            niz[1] = 2;
            niz[2] = 2;


            //testovi za getEnumList
            
            List<QLabValues.IQLabValue> listOfObj = new List<QLabValues.IQLabValue>();
            Memory_Access.QCharArray first = new Memory_Access.QCharArray(niz);
            listOfObj.Add(first);
            Memory_Access.QInt16Array second = new Memory_Access.QInt16Array(niz);
            listOfObj.Add(second);
            
            List<QLabValues.IQLabValueType> listOfTypes = new List<QLabValues.IQLabValueType>();
            listOfTypes.Add(QLabValues.IQLabValueType.QCharArray);
            listOfTypes.Add(QLabValues.IQLabValueType.QInt16Array);
            

            

            Assert.AreEqual(f.getEnumList(listOfObj).ElementAt(0), listOfTypes.ElementAt(0));
            Assert.AreEqual(f.getEnumList(listOfObj).ElementAt(1), listOfTypes.ElementAt(1));

            //testovi za canConcertEnums
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QBooleanArray(niz), QLabValues.IQLabValueType.QBooleanArray));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QCharArray(niz), QLabValues.IQLabValueType.QInt64Array));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QBooleanArray(niz), QLabValues.IQLabValueType.QFloat64Array));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QCharArray(niz), QLabValues.IQLabValueType.QFloat64Array));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QBooleanArray(niz), QLabValues.IQLabValueType.QUInt64Array));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QCharArray(niz), QLabValues.IQLabValueType.QUInt64Array));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QBooleanArray(niz), QLabValues.IQLabValueType.QBooleanArray));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QCharArray(niz), QLabValues.IQLabValueType.QCharArray));
            Assert.AreEqual(true, f.canConvertToEnum(new Memory_Access.QInt64Array(niz), QLabValues.IQLabValueType.QFloat64Array));


            //testovi za canConvertListToEnum
            Assert.AreEqual(true, f.canConvertListToEnum(new List<QLabValues.IQLabValue>(){new Memory_Access.QBooleanArray(niz),
            new Memory_Access.QCharArray(niz),new Memory_Access.QFloat64Array(niz) },QLabValues.IQLabValueType.QFloat64Array));

            Assert.AreEqual(true, f.canConvertListToEnum(new List<QLabValues.IQLabValue>() { 
            new Memory_Access.QInt64Array(niz), new Memory_Access.QInt64Array(niz), new Memory_Access.QFloat64Array(niz)}, QLabValues.IQLabValueType.QFloat64Array));

            Assert.AreEqual(false, f.canConvertListToEnum(new List<QLabValues.IQLabValue>() { 
            new Memory_Access.QInt64Array(niz), new Memory_Access.QInt64Array(niz), new Memory_Access.QFloat64Array(niz)}, QLabValues.IQLabValueType.QInt64Array));

            Assert.AreEqual(true, f.canConvertListToEnum(new List<QLabValues.IQLabValue>() { 
            new Memory_Access.QUInt64Array(niz), new Memory_Access.QInt64Array(niz)},QLabValues.IQLabValueType.QInt64Array));
        
            //testovi za checkDimensions
            Assert.AreEqual(true, f.checkDimensions(new Memory_Access.QInt64Array(niz), new Memory_Access.QInt64Array(niz)));
            Assert.AreEqual(false, f.checkDimensions(new Memory_Access.QInt64Array(new int[] { 1,2,3,4,5}), new Memory_Access.QInt64Array(new int[] { 2,3,4})));
            Assert.AreEqual(false, f.checkDimensions(new Memory_Access.QInt64Array(new int[] { 1, 2, 3, 4, 5 }), new Memory_Access.QInt64Array(new int[] { 1, 2, 3, 4, 6 })));

        
        }


    }
}
